<?php

use App\Http\Controllers\admin\AdminController;
use App\Http\Controllers\admin\ApprovalController;
use App\Http\Controllers\admin\ApprovalFlowController;
use App\Http\Controllers\admin\ApprovalNodeController;
use App\Http\Controllers\admin\AttendanceShiftController;
use App\Http\Controllers\admin\CompanyController;
use App\Http\Controllers\admin\DashboardController;
use App\Http\Controllers\admin\LaborAttendanceController;
use App\Http\Controllers\admin\LaborBlackController;
use App\Http\Controllers\admin\LaborCompanyContractController;
use App\Http\Controllers\admin\LaborCompanyController;
use App\Http\Controllers\admin\LaborController;
use App\Http\Controllers\admin\LaborExitController;
use App\Http\Controllers\admin\LaborTeamContractController;
use App\Http\Controllers\admin\LaborTeamController;
use App\Http\Controllers\admin\ProjectController;
use App\Http\Controllers\admin\PurchaseController;
use App\Http\Controllers\admin\RoleController;
use App\Http\Controllers\admin\WarehouseController;
use App\Http\Controllers\admin\WarehouseInController;
use App\Http\Controllers\admin\WarehouseOutController;
use App\Http\Controllers\admin\WarehouseRmaController;
use App\Http\Controllers\UploadFileController;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/


require __DIR__ . '/read.php';

Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
    return $request->user();
});

Route::post('/labor/login', [App\Http\Controllers\LaborAttendanceController::class, 'login']);

Route::get('/project/{number}', [App\Http\Controllers\ProjectController::class, 'show']);
Route::put('/purchase', [App\Http\Controllers\PurchaseController::class, 'store']);
Route::post('/upload', [UploadFileController::class, 'frontend']);


Route::group(['middleware' => ['auth:api']], function () {
    Route::post('/labor/attendance', [App\Http\Controllers\LaborAttendanceController::class, 'index']);
    Route::put('/labor/face', [App\Http\Controllers\LaborAttendanceController::class, 'face']);
    Route::put('/labor/attendance', [App\Http\Controllers\LaborAttendanceController::class, 'store']);
    Route::get('/projecTteam/{number}', [App\Http\Controllers\ProjectController::class, 'projecTteam']);
});


Route::prefix('admin')->group(function () {

    Route::post('/login', [AdminController::class, 'login']);

    Route::group(['middleware' => ['auth:admin_api']], function () {
        Route::post('/test', [App\Http\Controllers\TestController::class, 'index']);

        Route::get('/dashboard/console', [DashboardController::class, 'console'])->middleware('request.filter');
        Route::get('/info', [AdminController::class, 'info']);
        Route::post('/upload', [UploadFileController::class, 'upload'])->middleware('request.filter');

        Route::post('/company', [CompanyController::class, 'index'])->middleware('request.filter');
        Route::patch('/company', [CompanyController::class, 'update'])->middleware('request.filter');

        Route::get('/user/{id}', [AdminController::class, 'show'])->middleware('request.filter');
        Route::post('/user', [AdminController::class, 'index'])->middleware('request.filter');
        Route::put('/user', [AdminController::class, 'store'])->middleware('request.filter');
        Route::patch('/user', [AdminController::class, 'update'])->middleware('request.filter');
        Route::delete('/user/{id}', [AdminController::class, 'delete'])->middleware('request.filter');
        Route::patch('/auth', [AdminController::class, 'updateAuth'])->middleware('request.filter');

        Route::post('/role', [RoleController::class, 'index'])->middleware('request.filter');
        Route::post('/role/all', [RoleController::class, 'all'])->middleware('request.filter');
        Route::post('/role/user', [RoleController::class, 'user'])->middleware('request.filter');
        Route::put('/role', [RoleController::class, 'store'])->middleware('request.filter');
        Route::patch('/role', [RoleController::class, 'update'])->middleware('request.filter');
        Route::delete('/role/{id}', [RoleController::class, 'delete'])->middleware('request.filter');


        Route::post('/project/team', [ProjectController::class, 'teams'])->middleware('request.filter');
        Route::get('/project/team/{id}', [ProjectController::class, 'teamInfo'])->middleware('request.filter');
        Route::put('/project/team', [ProjectController::class, 'storeTeam'])->middleware('request.filter');
        Route::patch('/project/team', [ProjectController::class, 'updateTeam'])->middleware('request.filter');
        Route::delete('/project/team/{id}', [ProjectController::class, 'deleteTeam'])->middleware('request.filter');

        Route::get('/project/{id}', [ProjectController::class, 'show'])->middleware('request.filter');
        Route::post('/project', [ProjectController::class, 'index'])->middleware('request.filter');
        Route::post('/project/all', [ProjectController::class, 'all'])->middleware('request.filter');
        Route::post('/project/team', [ProjectController::class, 'teams'])->middleware('request.filter');
        Route::post('/project/auth', [ProjectController::class, 'auth'])->middleware('request.filter');
        Route::put('/project', [ProjectController::class, 'store'])->middleware('request.filter');
        Route::patch('/project', [ProjectController::class, 'update'])->middleware('request.filter');
        Route::delete('/project/{id}', [ProjectController::class, 'delete'])->middleware('request.filter');

        Route::get('/labor/company/contract/{id}', [LaborCompanyContractController::class, 'show'])->middleware('request.filter');
        Route::post('/labor/company/contract', [LaborCompanyContractController::class, 'index'])->middleware('request.filter');
        Route::put('/labor/company/contract', [LaborCompanyContractController::class, 'store'])->middleware('request.filter');
        Route::patch('/labor/company/contract', [LaborCompanyContractController::class, 'update'])->middleware('request.filter');
        Route::delete('/labor/company/contract/{id}', [LaborCompanyContractController::class, 'delete'])->middleware('request.filter');

        Route::get('/labor/company/{id}', [LaborCompanyController::class, 'show'])->middleware('request.filter');
        Route::post('/labor/company', [LaborCompanyController::class, 'index'])->middleware('request.filter');
        Route::post('/labor/company/all', [LaborCompanyController::class, 'all'])->middleware('request.filter');
        Route::put('/labor/company', [LaborCompanyController::class, 'store'])->middleware('request.filter');
        Route::patch('/labor/company', [LaborCompanyController::class, 'update'])->middleware('request.filter');
        Route::delete('/labor/company/{id}', [LaborCompanyController::class, 'delete'])->middleware('request.filter');

        Route::get('/labor/team/contract/{id}', [LaborTeamContractController::class, 'show'])->middleware('request.filter');
        Route::post('/labor/team/contract', [LaborTeamContractController::class, 'index'])->middleware('request.filter');
        Route::put('/labor/team/contract', [LaborTeamContractController::class, 'store'])->middleware('request.filter');
        Route::patch('/labor/team/contract', [LaborTeamContractController::class, 'update'])->middleware('request.filter');
        Route::delete('/labor/team/contract/{id}', [LaborTeamContractController::class, 'delete'])->middleware('request.filter');

        Route::get('/labor/team/{id}', [LaborTeamController::class, 'show'])->middleware('request.filter');
        Route::post('/labor/team', [LaborTeamController::class, 'index'])->middleware('request.filter');
        Route::post('/labor/team/all', [LaborTeamController::class, 'all'])->middleware('request.filter');
        Route::put('/labor/team', [LaborTeamController::class, 'store'])->middleware('request.filter');
        Route::patch('/labor/team', [LaborTeamController::class, 'update'])->middleware('request.filter');
        Route::delete('/labor/team/{id}', [LaborTeamController::class, 'delete'])->middleware('request.filter');

        Route::post('/labor/black', [LaborBlackController::class, 'index'])->middleware('request.filter');
        Route::put('/labor/black', [LaborBlackController::class, 'store'])->middleware('request.filter');
        Route::delete('/labor/black/{id}', [LaborBlackController::class, 'delete'])->middleware('request.filter');

        Route::get('/labor/exit/{id}', [LaborExitController::class, 'show'])->middleware('request.filter');
        Route::post('/labor/exit', [LaborExitController::class, 'index'])->middleware('request.filter');
        Route::put('/labor/exit', [LaborExitController::class, 'store'])->middleware('request.filter');
        Route::patch('/labor/exit', [LaborExitController::class, 'update'])->middleware('request.filter');
        Route::delete('/labor/exit/{id}', [LaborExitController::class, 'delete'])->middleware('request.filter');

        Route::get('/labor/{id}', [LaborController::class, 'show'])->middleware('request.filter');
        Route::post('/labor', [LaborController::class, 'index'])->middleware('request.filter');
        Route::put('/labor', [LaborController::class, 'store'])->middleware('request.filter');
        Route::put('/labor/batch', [LaborController::class, 'storeBatch'])->middleware('request.filter');
        Route::patch('/labor', [LaborController::class, 'update'])->middleware('request.filter');
        Route::delete('/labor/{id}', [LaborController::class, 'delete'])->middleware('request.filter');

        Route::get('/attendance/shift/{id}', [AttendanceShiftController::class, 'show'])->middleware('request.filter');
        Route::post('/attendance/shift', [AttendanceShiftController::class, 'index'])->middleware('request.filter');
        Route::put('/attendance/shift', [AttendanceShiftController::class, 'store'])->middleware('request.filter');
        Route::patch('/attendance/shift', [AttendanceShiftController::class, 'update'])->middleware('request.filter');
        Route::delete('/attendance/shift/{id}', [AttendanceShiftController::class, 'delete'])->middleware('request.filter');

        Route::post('/labor/attendance', [LaborAttendanceController::class, 'index'])->middleware('request.project_filter');
        Route::post('/labor/attendance/laborStatistics', [LaborAttendanceController::class, 'laborStatistics'])->middleware('request.project_filter');

        Route::post('/labor/salary/summary', [LaborController::class, 'salarySummary'])->middleware('request.filter');//工资汇总


        //审批流程
        Route::get('/approval/flow/{id}', [ApprovalFlowController::class, 'show'])->middleware('request.filter');
        Route::post('/approval/flow', [ApprovalFlowController::class, 'index'])->middleware('request.filter');
        Route::put('/approval/flow', [ApprovalFlowController::class, 'store'])->middleware('request.filter');
        Route::patch('/approval/flow', [ApprovalFlowController::class, 'update'])->middleware('request.filter');
        Route::delete('/approval/flow/{id}', [ApprovalFlowController::class, 'delete'])->middleware('request.filter');

        //审批流程
        Route::get('/approval/node/{id}', [ApprovalNodeController::class, 'show'])->middleware('request.filter');
        Route::post('/approval/node', [ApprovalNodeController::class, 'index'])->middleware('request.filter');
        Route::put('/approval/node', [ApprovalNodeController::class, 'store'])->middleware('request.filter');
        Route::patch('/approval/node', [ApprovalNodeController::class, 'update'])->middleware('request.filter');

        //审批
        Route::get('/approval/{id}', [ApprovalController::class, 'show'])->middleware('request.filter');
        Route::post('/approval', [ApprovalController::class, 'index'])->middleware('request.filter');
        Route::post('/approval/wait', [ApprovalController::class, 'wait'])->middleware('request.filter');
        Route::put('/approval', [ApprovalController::class, 'launch'])->middleware('request.filter');
        Route::post('/approval/review', [ApprovalController::class, 'review'])->middleware('request.filter');

        //采购申请
        Route::get('/purchase/{id}', [PurchaseController::class, 'show'])->middleware('request.filter');
        Route::post('/purchase', [PurchaseController::class, 'index'])->middleware('request.filter');
        Route::post('/purchase/all', [PurchaseController::class, 'all'])->middleware('request.filter');
        Route::put('/purchase', [PurchaseController::class, 'store'])->middleware('request.filter');
        Route::patch('purchase', [PurchaseController::class, 'update'])->middleware('request.filter');
        Route::delete('/purchase/{id}', [PurchaseController::class, 'delete'])->middleware('request.filter');


        Route::get('/warehouse/ins/{id}', [WarehouseInController::class, 'show'])->middleware('request.filter');
        Route::get('/warehouse/outs/{id}', [WarehouseOutController::class, 'show'])->middleware('request.filter');
        Route::get('/warehouse/rma/{id}', [PurchaseController::class, 'show'])->middleware('request.filter');
        Route::get('/warehouse/{id}', [WarehouseController::class, 'show'])->middleware('request.filter');
        Route::post('/warehouse', [WarehouseController::class, 'index'])->middleware('request.filter');
        Route::post('/warehouse/all', [WarehouseController::class, 'all'])->middleware('request.filter');
        Route::post('/warehouse/ins', [WarehouseInController::class, 'index'])->middleware('request.filter');
        Route::put('/warehouse/ins', [WarehouseInController::class, 'store'])->middleware('request.filter');
        Route::patch('/warehouse/ins', [WarehouseInController::class, 'update'])->middleware('request.filter');
        Route::patch('/warehouse/ins/confirm', [WarehouseInController::class, 'confirm'])->middleware('request.filter');
        Route::post('/warehouse/outs', [WarehouseOutController::class, 'index'])->middleware('request.filter');
        Route::put('/warehouse/outs', [WarehouseOutController::class, 'store'])->middleware('request.filter');


        Route::post('/warehouse/rma', [WarehouseRmaController::class, 'index'])->middleware('request.filter');
        Route::put('/warehouse/rma', [WarehouseRmaController::class, 'store'])->middleware('request.filter');
        Route::patch('warehouse/rma', [WarehouseRmaController::class, 'update'])->middleware('request.filter');
    });

});
